home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 July: Mac OS SDK / Dev.CD Jul 97 SDK1.toast / Development Kits (Disc 1) / Installer SDK Cornucopia 1.0.2 / Script Examples / Simple Atom Extender / DirectCopySCVersExt.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-09-26  |  2.1 KB  |  61 lines  |  [TEXT/MPS ]

  1. //
  2. //    File:        InstaCompOneSCVersExt.c
  3. //
  4. //                This file contains the source code for the DirectCopy Vers Info
  5. //                ScriptCheck extension function.  Since our source files are in the regular
  6. //                format (not compressed or otherwise changed and unreadable by normal
  7. //                means) we can get the version information directly from the 'vers' (1)
  8. //                resource.  In this example, we assume that we cannot get version information
  9. //                from a source resource, and, if our source data is determined to be a resource,
  10. //                we simply return an fnfErr.  Returning any other result besides noErr tells
  11. //                ScriptCheck to use the information from the actual source file found on the
  12. //                source disk and disregard any information passed back through the parameter block.
  13. //
  14. //    Copyright:    © 1996 by Apple Computer, Inc., all rights reserved.
  15. //
  16. //
  17.  
  18.  
  19.  
  20. #include "TargetVersMgt.h"
  21.  
  22. #include <Errors.h>
  23. #include <Files.h>
  24. #include <Resources.h>
  25.  
  26. OSErr main( TargetVersPBPtr theTargetVersPBPtr )
  27. {
  28.     OSErr            theErr                     = noErr;
  29.     short            savedResFile             = CurResFile();
  30.     Handle            theResourceHdl;
  31.     SInt16             fileRefNum;
  32.     
  33.     if( theTargetVersPBPtr->fFileVers.fSrcDataType                        // If we are looking at a resource
  34.         == kVersTypeIsRsrc )
  35.     {
  36.         theErr = fnfErr;    // This depends on the resource format, and cannot be generic.
  37.     }
  38.     else
  39.     {
  40.                                                                                     // open source file to make it cur res file
  41.         fileRefNum = HOpenResFile(    theTargetVersPBPtr->fFileVers.fSrcFSSpec.vRefNum,     
  42.                                     theTargetVersPBPtr->fFileVers.fSrcFSSpec.parID,     
  43.                                     theTargetVersPBPtr->fFileVers.fSrcFSSpec.name,         
  44.                                     fsRdPerm );                                            
  45.         theErr = ResError();
  46.         if (theErr != noErr) return theErr;                                                
  47.                                                                                     // get a handle to our resource
  48.         theResourceHdl = Get1Resource( 'vers', 1);
  49.                                         
  50.         theErr = ResError();
  51.         if (theErr != noErr) return theErr;                                                
  52.  
  53.         theTargetVersPBPtr->fFileVers.fTgtVersionNum = **((long**) theResourceHdl); // copy first long of vers 1
  54.                                                                                     // this is our vers in BCD format
  55.         CloseResFile( fileRefNum );
  56.         UseResFile( savedResFile );
  57.  
  58.     }
  59.     
  60.     return theErr;
  61. }